<template>
  <div>
    <van-nav-bar
    title="个人信息"
    left-text="返回"
    right-text=""
    left-arrow
    @click-left="()=>{this.$router.go(-1)}"
    />
    <p v-if="userstate&&userstate.audit_state=='审核不通过'" style="color:#f00;padding:0 16px;">温馨提醒：{{userstate.audit_remark}} ，请修改!</p>
    <el-form
        label-position="left"
        :label-width="'150px'"
        :model="formLabelAlignA"
        v-loading="loading"
        class="from"
    >
        <siteInfor style="background:#fff;" :userInfo='valueObj' ref="siteInfor"></siteInfor>
    </el-form>
  </div>
</template>

<script>
import { userinfo, passwordEdit ,applyList} from "@/api/admin.js";
import { mapGetters } from "vuex";
import { getsubject_id, getsubjectTitle,getPhone,getGender ,getuserstate} from "@/utils/auth";
import siteInfor from '@/components/siteInfor'
export default {
  data() {
    return {
      formLabelAlignA: {
        oldpassword: "",
        newpassword: "",
        subjectTitle: "",
        name: "",
        gender: "",
        phone: "",
        company:'',
        gz:'',
      },
      valueObj:{},
      loading: false,
      userstate:getuserstate()&&getuserstate()!='undefined'?JSON.parse(getuserstate()):null,
    };
  },
  computed: {
    ...mapGetters(["userinfor", "nickname", "adminUserId",'initObj']),
  },
  components:{siteInfor},
  methods: {
    //修改密码 提交
    commit() {
      if (!this.formLabelAlignA.oldpassword) {
        return this.$message.error("原密码不能为空");
      }
      if (!this.formLabelAlignA.newpassword) {
        return this.$message.error("新密码不能为空");
      }
      this.loading = true;
      passwordEdit({
        password_old: this.formLabelAlignA.oldpassword,
        password_new: this.formLabelAlignA.newpassword,
      }).then((res) => {
        if (res.code == 200) {
          this.loading = false;
          this.$message.success("密码修改成功");
          this.$router.push("/login");
        }
      });
    },
  },
  created() {
    this.formLabelAlignA.subjectTitle = getsubjectTitle();
    this.userinfor.map(item=>{
        if(item.subject_id==getsubject_id()){
          this.valueObj=item
          this.formLabelAlignA.phone=item.phone
          this.formLabelAlignA.company=item.company
          this.formLabelAlignA.gz=item.gz
          this.formLabelAlignA.gender=getGender()
        }
    })
    this.valueObj.nickname=this.nickname
    this.valueObj.username=this.adminUserId
    this.valueObj.phone=getPhone()
    this.valueObj.subjectTitle=getsubjectTitle()
  },
  mounted() {
    this.$refs.siteInfor.gzChange(this.formLabelAlignA.gz)
  },
};
</script>

<style lang="scss" scoped>
.from{
   padding:16px;
//    height: calc(100vh - 46px);
   overflow: auto;
}
</style>